package com.zoo.diannaopeijian.service.impl;

import com.zoo.diannaopeijian.common.page.Page;
import com.zoo.diannaopeijian.common.util.CheckUtil;
import com.zoo.diannaopeijian.domain.ShipmentRecord;
import com.zoo.diannaopeijian.mapper.ShipmentRecordMapper;
import com.zoo.diannaopeijian.service.ShipmentRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 出货记录服务实现类
 */
@Service
public class ShipmentRecordServiceImpl implements ShipmentRecordService {
    @Resource
    private ShipmentRecordMapper shipmentRecordMapper;

    @Override
    public boolean insertShipmentRecord(ShipmentRecord shipmentRecord) {
        if (CheckUtil.allNullBeanCheck(shipmentRecord)) {
            return true;
        }
        return shipmentRecordMapper.insertSelective(shipmentRecord) == 1;
    }

    @Override
    public List<Map> getShipmentRecord(Date from, Date to, String staffName) {
        return shipmentRecordMapper.selectShipmentRecord(from, to, staffName);
    }

    @Override
    public List getShipmentRecordWithPage(Date from, Date to, String staffName, Page page) {
        if (page != null) {
            page.onPage();
        }

        return getShipmentRecord(from, to, staffName);
    }
}
